import { useSelector, shallowEqual, useDispatch } from "react-redux"
import { StoreState } from "@store/index"

// 获取 store 中数据，默认比较提升性能
export default function useStoreState(...props: (keyof StoreState)[]) {
  const state = useSelector(state => {
    const obj: Record<string, any> = {}
    props.forEach(prop => { obj[prop] = state[prop] })
    return obj
  }, shallowEqual)
  return state
}
